package com.ali.sofa.config;

import com.ali.sofa.domain.Cat;
import com.ali.sofa.domain.Dog;
import com.ali.sofa.util.LinuxSystem;
import com.alibaba.druid.FastsqlException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
//判断条件是LinuxSystem类的matches方法的返回值是否是true;
@Conditional(LinuxSystem.class)
public class ConditionConfig {
    //类路径下是否有FastsqlException这个类
    @Bean
    @ConditionalOnClass(name="com.alibaba.druid.FastsqlException")
    public Cat cat01(){

        return  new Cat();
    }

    @ConditionalOnMissingClass({"com.alibaba.druid.FastsqlException"})
    @Bean
    public Dog dog01(){
        return new Dog();
    }



}
